package me.feng.service

import me.feng.entity.User
import me.feng.dao.impl.FriendsDao
import java.util.ArrayList
import me.feng.domain.Friends
import java.util.UUID

class FriendsService extends BaseService{
  import java.util.{List => JList}
  
  val dao = new FriendsDao(getSession)

  def getMyFriends(uid:String):JList[User] = withTransaction{
    val mList = dao.getMyFrinds(uid)
    val uList = new ArrayList[User]
    for(i <- 0 until mList.size()){
      uList.add(User.member2User(mList.get(i)))
    }
    uList
  }
  
  def addFriend(uid:String,u:User) = {
    val friend = new Friends
    friend.id = UUID.randomUUID().toString()
    friend.uid = uid
    friend.fid = u.id
    friend.category = "0"
    dao.save(friend)
  }
}